package 赛码.微众银行;

import java.math.BigInteger;
import java.util.Scanner;

public class 阶乘求位数 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i1 = sc.nextInt();
        if (i1==0) {
            System.out.println(0);
            return;
        }
        String s = function1(i1);
        for(int i =s.length()-1;i>=0;i--){
            if (s.substring(i-1,i).equals("0")) {
                continue;
            }else {
                System.out.println(s.substring(i-1,i));
                break;
            }
        }
    }

    private static String function1(int nextInt) {
        BigInteger sum = new BigInteger("1");
        for(int i=1;i<=nextInt;i++){
            BigInteger sum1 = new BigInteger(String.valueOf(i));
            sum = sum.multiply(sum1);
        }
        return String.valueOf(sum);
    }

}
